<template>
  <div class="container">
    <img class="banner" src="@/assets/user-banner.png" alt="" />
    <div class="wrap">
      <div class="main">
        <div class="left">
          <div class="info">
            <div class="avatar"><img :src="info.avatar" alt="" /></div>
            <div class="name">{{ info.nickname }}</div>
            <div class="email">{{ info.email }}</div>
            <div class="account">
              <div class="num">钱包余额：￥{{ info.money }}</div>
              <router-link to="withdrawal" class="btn pointer">
                提现 <img src="@/assets/user-icon6.png" alt="" />
              </router-link>
            </div>
            <div class="account">
              <div class="num">
                可上传作品：
                <span class="numShow"
                  >{{ info.upload_count }} / {{ info.upload_image_count }}</span
                >
              </div>
              <router-link to="recharge" class="btn pointer">
                购买 <img src="@/assets/user-icon6.png" alt="" />
              </router-link>
            </div>
          </div>
          <div class="menu">
            <router-link to="user">
              <img src="@/assets/user-icon0.png" alt="" />
              个人中心
            </router-link>
            <router-link to="record">
              <img src="@/assets/user-icon3.png" alt="" />
              购买记录
            </router-link>
            <router-link to="follow">
              <img src="@/assets/user-icon1.png" alt="" />
              我的关注
            </router-link>
            <router-link to="collect">
              <img src="@/assets/user-icon2.png" alt="" />
              我的收藏
            </router-link>

            <router-link to="works">
              <img src="@/assets/user-icon4.png" alt="" />
              我的作品
            </router-link>
            <router-link to="message">
              <img src="@/assets/user-icon5.png" alt="" />
              我的消息
            </router-link>
          </div>
        </div>
        <div class="right">
          <router-view />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "NavBar",
  data() {
    return {
      info: {},
    };
  },
  mounted() {
    this.getUser();
  },
  methods: {
    getUser() {
      this.$post("/user/userinfo").then((res) => {
        this.info = res.data.userinfo;
      });
    },
  },
};
</script>

<style scoped lang="scss">
.container {
  background: #f8f8f8;
}
.banner {
  height: 300px;
}
.main {
  display: flex;
  justify-content: space-between;
  padding: 30px 0 60px;
}
.left {
  width: 360px;

  .info {
    padding: 24px;
    background: #fff;
    .avatar {
      width: 120px;
      height: 120px;
      border-radius: 50%;
      overflow: hidden;
      margin: 0 auto;
      img {
        height: 100%;
      }
    }
    .name {
      text-align: center;
      font-size: 24px;
      margin-top: 10px;
    }
    .email {
      color: #999;
      text-align: center;
    }
    .account {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-top: 10px;
      .btn {
        color: #999;
        display: flex;
        align-items: center;
        img {
          width: 17px;
          height: 18px;
          display: block;
          margin-left: 6px;
        }
      }
      .numShow{
        color: #3c3b8b;
      }
    }
  }

  .menu {
    display: flex;
    background: #917bbd;
    flex-wrap: wrap;
    font-size: 20px;
    a {
      display: flex;
      width: 50%;
      justify-content: center;
      align-items: center;
      color: #fff;
      height: 120px;
      flex-direction: column;
      img {
        width: 36px;
        height: 36px;
      }
    }
  }
}
.right {
  width: calc(100% - 385px);
  background: #fff;
  padding: 20px;
}
@media screen and (max-width: 768px) {
  .main {
    display: block;
  }
  .left {
    width: 100%;
  }
  .right {
    width: 100%;
    padding: 20px;
  }
  .left .menu {
    font-size: 16px;
    a {
      width: calc(100% / 3);
      height: 90px;
      img {
        width: 30px;
        height: 30px;
      }
    }
  }
}
</style>
